﻿using Class_Entity.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccess.ObjectTwo
{
   public class D_Insert
    {
        ConnectionToDataBase ex = new ConnectionToDataBase();
        DataTable tb = new DataTable();
        Cities kx = new Cities();
       Companies gx = new Companies();
       C_Services ser = new C_Services();
       Delivery_free_polices dfp = new Delivery_free_polices();
       C_News ne = new C_News();
       public bool InsertCompany(Companies fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[6];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.COMPANY_NAME;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.COMPANY_CODE;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.COMPANY_PHONE;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.VarChar);
           sqlParameters[3].Value = fx.COMPANY_ADDRESS;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.VarChar);
           sqlParameters[4].Value = fx.COMPANY_EMAIL;
           sqlParameters[5] = new SqlParameter("@F", SqlDbType.VarChar);
           sqlParameters[5].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertCompany", sqlParameters);
       }
       public bool InsertCity(Cities fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[3];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.CITY_CODE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.CITY_NAME;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertCity", sqlParameters);
       }
       public bool InsertService(C_Services fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[3];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.SERVICE_CODE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.SERVICE_NAME;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.VarChar);
           sqlParameters[2].Value = fx.DESCRIPTION;
           return ex.executeInserQuery("InsertService", sqlParameters);
       }
       public bool InsertFeePolicy(Delivery_free_polices fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[7];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.Int);
           sqlParameters[0].Value = fx.SERVICE_ID;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.Float);
           sqlParameters[1].Value = fx.DISTANCE_FROM;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.Float);
           sqlParameters[2].Value = fx.DISTANCE_TO;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.Float);
           sqlParameters[3].Value = fx.FEE_PER_KM;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.Float);
           sqlParameters[4].Value = fx.WEIGHT_FROM;
           sqlParameters[5] = new SqlParameter("@F", SqlDbType.Float);
           sqlParameters[5].Value = fx.WEIGHT_TO;
           sqlParameters[6] = new SqlParameter("@G", SqlDbType.Float);
           sqlParameters[6].Value = fx.FEE_PER_KG;
           return ex.executeInserQuery("InsertFeePolicy", sqlParameters);
       }
       public bool InsertNews(C_News fx)
       {
           SqlParameter[] sqlParameters = new SqlParameter[5];
           sqlParameters[0] = new SqlParameter("@A", SqlDbType.VarChar);
           sqlParameters[0].Value = fx.TITLE;
           sqlParameters[1] = new SqlParameter("@B", SqlDbType.VarChar);
           sqlParameters[1].Value = fx.SUBJECT;
           sqlParameters[2] = new SqlParameter("@C", SqlDbType.NText);
           sqlParameters[2].Value = fx.BODY;
           sqlParameters[3] = new SqlParameter("@D", SqlDbType.DateTime);
           sqlParameters[3].Value = fx.CREATE_DATE;
           sqlParameters[4] = new SqlParameter("@E", SqlDbType.Bit);
           sqlParameters[4].Value = fx.STATUS;
           return ex.executeInserQuery("InsertNews", sqlParameters);
       }
    }
}
